package com.ruoyi.publish.domain;

import com.ruoyi.publish.service.BrowseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class radomnInsert {
    @Autowired
    private BrowseService browseService;
    /**
     * 定时随机插入浏览记录
     */
    @Scheduled(cron = "0 0 */2 * * ?")//两小时执行一次
    public void scheduledInsertBrowse() {
        try {
            int count = 10;
            int result = browseService.insertRandom(count);
            System.out.println(result);
        } catch (Exception e) {
            System.out.println("定时任务执行失败");
        }
    }
}
